package aop;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

// MethodInterceptor用于在调用方法前后进行额外的处理
public class CustomMethodInterceptor implements MethodInterceptor {
    private Log log = LogFactory.getLog(this.getClass());

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        log.info("开始执行方法" + methodInvocation.getMethod());
        // 方法调用器继续生效
        Object result = methodInvocation.proceed();
        log.info("执行方法" + methodInvocation.getMethod() + "结束");
        return result;
    }
}
